/* 
 * Drawing missile sprite on NES
 * uses neslib by shiru
 *      nesdoug by Doug Fraker
 */

#include "LIB/neslib.h"
#include "LIB/nesdoug.h"

#pragma bss-name(push, "ZEROPAGE")

/* sprite coordinates */
unsigned char x_pos = 0x40;
unsigned char y_pos = 0x40;

/* sprite index */
unsigned char spr_idx;

/*
 * Background palette :
 * Black, Grey, Light Grey, White
 */
const unsigned char palette_bg[]={
  0x0f, 0x00, 0x10, 0x30,
  0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

/*
 * Sprite palette :
 * Black, Grey, Light Grey, White
 */
const unsigned char palette_sp[]={
  0x0f, 0x00, 0x10, 0x30,
  0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

void main (void) {

  ppu_off();

  pal_bg(palette_bg);
  pal_spr(palette_sp);

  bank_bg(0);
  bank_spr(1);

  ppu_on_all();

  while (1) {

    ppu_wait_nmi();

    oam_clear();

    spr_idx = 0;

    spr_idx = oam_spr(x_pos, y_pos, 0, 0, spr_idx);

    ++x_pos;
  }
}
